package bishizhuanyong.sl0;

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import java.util.HashSet;
import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int n1=s.nextInt();
        int n2=s.nextInt();
        int n3 = s.nextInt();
        s.nextLine();
        String s1=s.nextLine();
        String s2=s.nextLine();
        String s3=s.nextLine();
        int n=s.nextInt();
        HashSet<String> set1= getSet(s1);
        HashSet<String> set2 = getSet(s2);
        HashSet<String> set3 = getSet(s3);
        s.nextLine();
        for (int i=0;i<n;i++){
            String jz = s.nextLine();
            process(jz,set1,set2,set3);
        }
    }

    public static void process(String s,HashSet<String> s1,HashSet<String> s2,HashSet<String> s3){
        String[] jzz= s.split(" ");
        boolean wei=false;
        for (int i=0;i<jzz.length;i++){
            if (!wei){
                if (s2.contains(jzz[i])){
                    if (i==0){
                        System.out.println("NO");
                        return;
                    }else
                        wei=true;
                }else if (!s1.contains(jzz[i])){
                    System.out.println("NO");
                    return;
                }
            }else {
                if (!s3.contains(jzz[i])){
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }

    public static HashSet<String> getSet(String s){
        String[] ss = s.split(" ");
        HashSet<String> res=new HashSet<>();
        for (int i=0;i<ss.length;i++)
            res.add(ss[i]);
        return res;
    }
}
